package com.example.demo01.Controller.webController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.example.demo01.Service.webService.XYValueService;
import com.example.demo01.utils.JSONPGUtils;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class XYValueController {
    //自动装配
    @Autowired
    private XYValueService xyValueService;

    //成员方法
    /******************************热力图分析——begin***********************************************/
    /**
     * 获取全焦作范围内的报警次数统计信息
     * @return 全焦作范围内的报警次数集合
     */
    @RequestMapping("/xyvalue/GET/warninfo")
    public String getWarnInfoListInJiaoZuo(){
        return JSON.toJSONString(xyValueService.getWarnInfoListInJiaoZuo());
    }


    /**
     * 根据区县名称获取报警次数统计信息
     * @return 区县名称获取报警次数统计信息
     */
    @RequestMapping("/xyvalue/GET/warninfo/bydomain")
    public String getWarnInfoListByDomainName(
            @RequestParam(value = "domain") String domain){
        return JSON.toJSONString(xyValueService.getWarnInfoListByDomainName(domain));
    }

    @RequestMapping("/xyvalue/GET/heatmaparray.json")
    public String getHeatMapJson(){
        //更新经纬度边界信息到heatmaparray.json文件中
        JSONPGUtils.getHeatMapArrayJsonInJiaoZuo();
        //调用工具类静态方法，通过文件流读取json文件内容
        return JSONPGUtils.getHeatMapJsonFileContent();
    }

    @RequestMapping("/xyvalue/GET/bydomain/heatmaparray.json")
    public String getHeatMapJson(
           @RequestParam(value = "domain") String domain
    ){
        //更新经纬度边界信息到heatmaparray.json文件中
        JSONPGUtils.getHeatMapArrayJsonByDomainName(domain);
        //调用工具类静态方法，通过文件流读取json文件内容
        return JSONPGUtils.getHeatMapJsonFileContent();
    }
    /******************************热力图分析——end***********************************************/

    /******************************插值分析——begin***********************************************/


    /**
     * 获取全焦作范围内的报警次数统计信息——经纬度坐标
     * @return 全焦作范围内的报警次数集合
     */
    @RequestMapping("/xyvalue/GET/warninfokriging")
    public String getWarnInfoListInJiaoZuoWGS84() { return JSON.toJSONString(xyValueService.getWarnInfoListInJiaoZuoWGS84()); }

    /**
     * 根据区县名称获取报警次数统计信息——投影坐标
     * @return 区县名称获取报警次数统计信息
     */
    @RequestMapping("/xyvalue/GET/warninfokriging/bydomain")
    public String getWarnInfoListByDomainNameWGS84(
            @RequestParam(value = "domain") String domain)
    {
        return JSON.toJSONString(xyValueService.getWarnInfoListByDomainNameWGS84(domain));
    }

    /**
     * 获取客户信息——投影坐标
     */
    @RequestMapping("/xyvalue/GET/userinfoheatmap")
    public String getUserInfoListInJiaoZuo() { return JSON.toJSONString(xyValueService.getUserInfoListInJiaoZuo()); }

    /**
     * 获取客户信息——经纬度坐标
     */
    @RequestMapping("/xyvalue/GET/userinfokriging")
    public String getUserInfoListInJiaoZuoWGS84() { return JSON.toJSONString(xyValueService.getUserInfoListInJiaoZuoWGS84()); }

    /******************************插值分析——end***********************************************/

    @Test
    public void test1(){
        List<Float> list=new ArrayList<>();
        list.add(1f);
        list.add(2f);
        list.add(3f);
        list.add(4f);
        list.add(5f);
        System.out.println(list.toString());
        System.out.println(JSONArray.parse("[113.205977195,35.31361327,113.202159025,35.31235129,113.20081792,35.31173549,113.199540945,35.310979325,113.18700933,35.30338484,113.186593065,35.303058335,113.178124275,35.294943945,113.177423185,35.294121495,113.17695892,35.293266935,113.176839225,35.292601025,113.176892195,35.292043355,113.177096195,35.29078706,113.177846895,35.287127015,113.1783723,35.285196865,113.17842525,35.284639195,113.178326825,35.28349969,113.178176935,35.2829735,113.177846965,35.282060855,113.177421915,35.28140045,113.17676159,35.28082778,113.174336625,35.2790064,113.172507885,35.27789798,113.17092264,35.27700787,113.168066495,35.275555955,113.1650091,35.27419109,113.163454235,35.273161145,113.16300134,35.272723865,113.16278149,35.272115405,113.162760035,35.271308535,113.163660275,35.268146945,113.164317185,35.26604747,113.16463199,35.265123245,113.168538225,35.253779615,113.1741425,35.25142427,113.175230105,35.251488235,113.17747017,35.2515036,113.179628475,35.250914735,113.180360285,35.25044944,113.181109635,35.24898366,113.181509125,35.247514605,113.18180451,35.244828325,113.179187835,35.244680635,113.17887218,35.24429662,113.17761644,35.241702,113.17775472,35.241155985,113.180462015,35.23853593,113.181767035,35.238742355,113.18278827,35.23786684,113.18356159,35.2350261,113.18380546,35.234130215,113.184470685,35.230981275,113.184724655,35.229736275,113.18482989,35.229156875,113.18477688,35.22862779,113.184187925,35.228137035,113.18296161,35.22712901,113.181982475,35.22639289,113.17961477,35.22468514,113.178471005,35.22389752,113.17746822,35.2232288,113.17613421,35.22238595,113.175893305,35.22202763,113.171988405,35.21602747,113.172337705,35.21288546,113.178154555,35.21418154,113.18037235,35.216148465,113.18407711,35.218464815,113.187261275,35.21941073,113.188449395,35.21738833,113.18838572,35.217364625,113.18834026,35.217352035,113.187700205,35.21712832,113.18690353,35.21684601,113.18656684,35.21672491,113.186485125,35.21669552,113.18550492,35.216340855,113.18529222,35.21626263,113.18483851,35.2160707,113.184630795,35.215982835,113.18399221,35.2157127,113.183496165,35.21550265,113.181597735,35.21469874,113.182103465,35.211350955,113.1871358,35.211887255,113.19114244,35.21018075,113.19356786,35.208085565,113.194425835,35.207344365,113.199345035,35.2039673,113.20278519,35.20408186,113.20305078,35.2040797,113.20385673,35.203940215,113.204933475,35.19732813,113.202418735,35.194907145,113.198749485,35.19458594,113.19890386,35.19355835,113.199526305,35.19027924,113.199843265,35.188703765,113.201121955,35.182347355,113.18474748,35.17825061,113.184358645,35.17868251,113.182697925,35.1805271,113.1755536,35.181605625,113.174969745,35.18214039,113.167769325,35.18873462,113.166296785,35.190530215,113.166283265,35.190546705,113.164574865,35.192629785,113.164487625,35.192997625,113.164265525,35.194132295,113.164045935,35.19462991,113.15795242,35.194875365,113.155982755,35.194634795,113.15558256,35.194154185,113.15435023,35.18955328,113.1544356,35.18887317,113.154764665,35.18666192,113.157045645,35.186960595,113.157184895,35.18538889,113.157079435,35.184330475,113.155603905,35.18420832,113.147959655,35.18425937,113.14414643,35.184623845,113.14314176,35.184726465,113.142558305,35.186115165,113.14061367,35.18780362,113.13708313,35.190092605,113.13242227,35.189665855,113.12906066,35.190247035,113.128462075,35.190350525,113.118552025,35.198594185,113.11379108,35.204449395,113.107513435,35.214072705,113.10663284,35.215675215,113.1065348,35.216292855,113.106400765,35.217137245,113.10643339,35.221879745,113.107286655,35.22965312,113.1076357,35.231865015,113.107937715,35.233778795,113.10446363,35.23636276,113.1032333,35.238343005,113.102267915,35.239896755,113.10031,35.243047725,113.098589215,35.245816845,113.09793661,35.246866975,113.09559186,35.24716209,113.095071275,35.24702266,113.09447535,35.246969365,113.08967266,35.247179655,113.089315815,35.247376675,113.089015545,35.24776356,113.087518185,35.250864265,113.087396595,35.25116324,113.0861009,35.25608414,113.086106335,35.256296105,113.086187665,35.25644315,113.08655108,35.256500495,113.08823078,35.256471505,113.088855875,35.25665157,113.089481505,35.25685282,113.089848735,35.257058535,113.090086755,35.257266475,113.090170165,35.25749407,113.092583465,35.26407841,113.094535715,35.269404055,113.094595055,35.2696999,113.094913205,35.27100915,113.097108775,35.275933235,113.097272615,35.27626969,113.09756514,35.276582705,113.09793302,35.276809585,113.098349325,35.27690839,113.10257768,35.279422045,113.107763725,35.286944585,113.11445707,35.29768499,113.11467658,35.298168875,113.11487081,35.29867441,113.11503752,35.29911682,113.1174143,35.30874195,113.117524535,35.30918833,113.11876969,35.31427704,113.118863855,35.314911555,113.122779425,35.320554395,113.12475174,35.323396415,113.12896943,35.329323325,113.129233075,35.32950953,113.13081248,35.33151741,113.131675225,35.332838135,113.131653945,35.333390955,113.131591835,35.33500441,113.131523935,35.336768365,113.13157414,35.33682162,113.131923405,35.33721657,113.132233785,35.337707855,113.13303572,35.33899268,113.133121645,35.33925343,113.13299074,35.34301075,113.13296316,35.343393835,113.13294545,35.34350837,113.13281927,35.34383394,113.13264715,35.34414501,113.132247065,35.344394085,113.132088175,35.344478615,113.131784725,35.34460969,113.13099922,35.34479014,113.130787545,35.344910165,113.1306322,35.34512978,113.130355015,35.34582302,113.130000615,35.346935645,113.12999918,35.34731914,113.130150045,35.34765908,113.13037369,35.34799459,113.130557385,35.348123365,113.135040285,35.349253315,113.135809635,35.349447215,113.138516925,35.350129495,113.141710395,35.350474895,113.14357208,35.35067621,113.145494155,35.34938411,113.14553798,35.349354645,113.14702728,35.348353425,113.147556115,35.348019425,113.14761207,35.347995245,113.148456345,35.34781793,113.14876625,35.347766055,113.15523804,35.34744211,113.155718885,35.34743353,113.155775455,35.34743252,113.155832025,35.347431515,113.171060485,35.35084261,113.173084465,35.351295805,113.17410144,35.35160434,113.17436593,35.351684575,113.175652675,35.35207493,113.17676591,35.352412635,113.17813467,35.352827835,113.1817884,35.35399073,113.183195045,35.35473043,113.186901845,35.3518935,113.18816029,35.350930305,113.192569345,35.347555395,113.194147075,35.34634762,113.197957335,35.34284694,113.19842495,35.34235154,113.200512185,35.33897487,113.200539205,35.33892801,113.200593255,35.338834285,113.20088801,35.338226095,113.20091408,35.33814448,113.200940165,35.338062845,113.20238709,35.33434598,113.205041525,35.327526345,113.205529135,35.32679924,113.207141545,35.325030975,113.208718065,35.32364135,113.209704505,35.322602705,113.210367195,35.321532165,113.210928405,35.32012328,113.2115182,35.318071255,113.21146696,35.31788319,113.211186265,35.31773713,113.21025919,35.317565075,113.20836408,35.31741072,113.207992225,35.31730411,113.20642279,35.315556145,113.206181015,35.315144745,113.206071385,35.31450414,113.205977195,35.31361327]"));
    }

}
